Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
4.85% |
11 / 227 |
|
3.62% |
8 / 221 |
|
0.39% |
1 / 258 |
|
0.00% |
0 / 15 |
CRAP | |
0.00% |
0 / 1 |
| PKPSchemaService | |
5.34% |
11 / 206 |
|
3.62% |
8 / 221 |
|
0.39% |
1 / 258 |
|
0.00% |
0 / 15 |
11211.85 | |
0.00% |
0 / 1 |
| get | |
61.11% |
11 / 18 |
|
57.14% |
8 / 14 |
|
6.25% |
1 / 16 |
|
0.00% |
0 / 1 |
47.37 | |||
| merge | |
0.00% |
0 / 16 |
|
0.00% |
0 / 17 |
|
0.00% |
0 / 84 |
|
0.00% |
0 / 1 |
72 | |||
| getSummaryProps | |
0.00% |
0 / 6 |
|
0.00% |
0 / 8 |
|
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
20 | |||
| getFullProps | |
0.00% |
0 / 6 |
|
0.00% |
0 / 6 |
|
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| getRequiredProps | |
0.00% |
0 / 4 |
|
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| getMultilingualProps | |
0.00% |
0 / 6 |
|
0.00% |
0 / 6 |
|
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| sanitize | |
0.00% |
0 / 16 |
|
0.00% |
0 / 18 |
|
0.00% |
0 / 34 |
|
0.00% |
0 / 1 |
72 | |||
| coerce | |
0.00% |
0 / 30 |
|
0.00% |
0 / 38 |
|
0.00% |
0 / 22 |
|
0.00% |
0 / 1 |
306 | |||
| getValidationRules | |
0.00% |
0 / 8 |
|
0.00% |
0 / 10 |
|
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
20 | |||
| addPropValidationRules | |
0.00% |
0 / 26 |
|
0.00% |
0 / 24 |
|
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
182 | |||
| formatValidationErrors | |
0.00% |
0 / 4 |
|
0.00% |
0 / 4 |
|
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| setDefaults | |
0.00% |
0 / 13 |
|
0.00% |
0 / 16 |
|
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
56 | |||
| getLocaleDefaults | |
0.00% |
0 / 7 |
|
0.00% |
0 / 8 |
|
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
20 | |||
| getDefault | |
0.00% |
0 / 29 |
|
0.00% |
0 / 30 |
|
0.00% |
0 / 27 |
|
0.00% |
0 / 1 |
240 | |||
| addMissingMultilingualValues | |
0.00% |
0 / 17 |
|
0.00% |
0 / 19 |
|
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
90 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @file classes/services/PKPSchemaService.php |
| 4 | * |
| 5 | * Copyright (c) 2014-2021 Simon Fraser University |
| 6 | * Copyright (c) 2000-2021 John Willinsky |
| 7 | * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. |
| 8 | * |
| 9 | * @class PKPSchemaService |
| 10 | * |
| 11 | * @ingroup services |
| 12 | * |
| 13 | * @brief Helper class for loading schemas, using them to sanitize and |
| 14 | * validate objects, and installing default data. |
| 15 | */ |
| 16 | |
| 17 | namespace PKP\services; |
| 18 | |
| 19 | use Exception; |
| 20 | use Illuminate\Support\Arr; |
| 21 | use Illuminate\Support\MessageBag; |
| 22 | use PKP\core\DataObject; |
| 23 | use PKP\plugins\Hook; |
| 24 | |
| 25 | /** |
| 26 | * @template T of DataObject |
| 27 | */ |
| 28 | class PKPSchemaService |
| 29 | { |
| 30 | public const SCHEMA_ANNOUNCEMENT = 'announcement'; |
| 31 | public const SCHEMA_AUTHOR = 'author'; |
| 32 | public const SCHEMA_CATEGORY = 'category'; |
| 33 | public const SCHEMA_CONTEXT = 'context'; |
| 34 | public const SCHEMA_DOI = 'doi'; |
| 35 | public const SCHEMA_DECISION = 'decision'; |
| 36 | public const SCHEMA_EMAIL_TEMPLATE = 'emailTemplate'; |
| 37 | public const SCHEMA_GALLEY = 'galley'; |
| 38 | public const SCHEMA_HIGHLIGHT = 'highlight'; |
| 39 | public const SCHEMA_INSTITUTION = 'institution'; |
| 40 | public const SCHEMA_ISSUE = 'issue'; |
| 41 | public const SCHEMA_PUBLICATION = 'publication'; |
| 42 | public const SCHEMA_REVIEW_ASSIGNMENT = 'reviewAssignment'; |
| 43 | public const SCHEMA_REVIEW_ROUND = 'reviewRound'; |
| 44 | public const SCHEMA_SECTION = 'section'; |
| 45 | public const SCHEMA_SITE = 'site'; |
| 46 | public const SCHEMA_SUBMISSION = 'submission'; |
| 47 | public const SCHEMA_SUBMISSION_FILE = 'submissionFile'; |
| 48 | public const SCHEMA_USER = 'user'; |
| 49 | public const SCHEMA_USER_GROUP = 'userGroup'; |
| 50 | public const SCHEMA_EVENT_LOG = 'eventLog'; |
| 51 | |
| 52 | /** @var array cache of schemas that have been loaded */ |
| 53 | private $_schemas = []; |
| 54 | |
| 55 | /** |
| 56 | * Get a schema |
| 57 | * |
| 58 | * - Loads the schema file and transforms it into an object |
| 59 | * - Passes schema through hook |
| 60 | * - Returns pre-loaded schemas on request |
| 61 | * |
| 62 | * @param string $schemaName One of the SCHEMA_... constants |
| 63 | * @param bool $forceReload Optional. Compile the schema again from the |
| 64 | * source files, bypassing any cached version. |
| 65 | * |
| 66 | * @return object |
| 67 | * |
| 68 | * @hook Schema::get::(schemaName) [[schema]] |
| 69 | * @hook Schema::get:: |
| 70 | */ |
| 71 | public function get($schemaName, $forceReload = false) |
| 72 | { |
| 73 | Hook::run('Schema::get::before::' . $schemaName, [&$forceReload]); |
| 74 | |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 76 | return $this->_schemas[$schemaName]; |
| 77 | } |
| 78 | |
| 79 | $schemaFile = sprintf('%s/lib/pkp/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 80 | if (file_exists($schemaFile)) { |
| 81 | $schema = json_decode(file_get_contents($schemaFile)); |
| 82 | if (!$schema) { |
| 83 | throw new Exception('Schema failed to decode. This usually means it is invalid JSON. Requested: ' . $schemaFile . '. Last JSON error: ' . json_last_error()); |
| 84 | } |
| 85 | } else { |
| 86 | // allow plugins to create a custom schema and load it via hook |
| 87 | $schema = new \stdClass(); |
| 88 | } |
| 89 | |
| 90 | // Merge an app-specific schema file if it exists |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 92 | if (file_exists($appSchemaFile)) { |
| 93 | $appSchema = json_decode(file_get_contents($appSchemaFile)); |
| 94 | if (!$appSchema) { |
| 95 | throw new Exception('Schema failed to decode. This usually means it is invalid JSON. Requested: ' . $appSchemaFile . '. Last JSON error: ' . json_last_error()); |
| 96 | } |
| 97 | $schema = $this->merge($schema, $appSchema); |
| 98 | } |
| 99 | |
| 100 | Hook::call('Schema::get::' . $schemaName, [&$schema]); |
| 101 | |
| 102 | $this->_schemas[$schemaName] = $schema; |
| 103 | |
| 104 | return $schema; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Merge two schemas |
| 109 | * |
| 110 | * Merges the properties of two schemas, updating the title, description, |
| 111 | * and properties definitions. |
| 112 | * |
| 113 | * If both schemas contain definitions for the same property, the property |
| 114 | * definition in the additional schema will override the base schema. |
| 115 | * |
| 116 | * @param object $baseSchema The base schema |
| 117 | * @param object $additionalSchema The additional schema properties to apply |
| 118 | * to $baseSchema. |
| 119 | * |
| 120 | * @return object |
| 121 | */ |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Get the summary properties of a schema |
| 151 | * |
| 152 | * Gets the properties of a schema which are considered part of the summary |
| 153 | * view presented in an API. |
| 154 | * |
| 155 | * @param string $schemaName One of the SCHEMA_... constants |
| 156 | * |
| 157 | * @return array List of property names |
| 158 | */ |
| 159 | public function getSummaryProps($schemaName) |
| 160 | { |
| 161 | $schema = $this->get($schemaName); |
| 162 | $props = []; |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 165 | $props[] = $propName; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | return $props; |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * Get all properties of a schema |
| 174 | * |
| 175 | * Gets the complete list of properties of a schema which are considered part |
| 176 | * of the full view presented in an API. |
| 177 | * |
| 178 | * @param string $schemaName One of the SCHEMA_... constants |
| 179 | * |
| 180 | * @return array List of property names |
| 181 | */ |
| 182 | public function getFullProps($schemaName) |
| 183 | { |
| 184 | $schema = $this->get($schemaName); |
| 185 | |
| 186 | $propNames = []; |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 188 | if (empty($propSchema->writeOnly)) { |
| 189 | $propNames[] = $propName; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | return $propNames; |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * Get required properties of a schema |
| 198 | * |
| 199 | * @param string $schemaName One of the SCHEMA_... constants |
| 200 | * |
| 201 | * @return array List of property names |
| 202 | */ |
| 203 | public function getRequiredProps($schemaName) |
| 204 | { |
| 205 | $schema = $this->get($schemaName); |
| 206 | |
| 207 | if (!empty($schema->required)) { |
| 208 | return $schema->required; |
| 209 | } |
| 210 | return []; |
| 211 | } |
| 212 | |
| 213 | /** |
| 214 | * Get multilingual properties of a schema |
| 215 | * |
| 216 | * @param string $schemaName One of the SCHEMA_... constants |
| 217 | * |
| 218 | * @return array List of property names |
| 219 | */ |
| 220 | public function getMultilingualProps($schemaName) |
| 221 | { |
| 222 | $schema = $this->get($schemaName); |
| 223 | |
| 224 | $multilingualProps = []; |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 226 | if (!empty($propSchema->multilingual)) { |
| 227 | $multilingualProps[] = $propName; |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | return $multilingualProps; |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * Sanitize properties according to a schema |
| 236 | * |
| 237 | * This method coerces properties to their appropriate type, and strips out |
| 238 | * properties that are not specified in the schema. |
| 239 | * |
| 240 | * @param string $schemaName One of the SCHEMA_... constants |
| 241 | * @param array $props Properties to be sanitized |
| 242 | * |
| 243 | * @return array The sanitized props |
| 244 | */ |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 272 | |
| 273 | /** |
| 274 | * Coerce a value to a variable type |
| 275 | * |
| 276 | * It will leave null values alone. |
| 277 | * |
| 278 | * @param string $type boolean, integer, number, string, array, object |
| 279 | * @param object $schema A schema defining this property |
| 280 | * |
| 281 | * @return mixed The value coerced to type |
| 282 | */ |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 286 | return $value; |
| 287 | } |
| 288 | switch ($type) { |
| 289 | case 'boolean': |
| 290 | return (bool) $value; |
| 291 | case 'integer': |
| 292 | return (int) $value; |
| 293 | case 'number': |
| 294 | return (float) $value; |
| 295 | case 'string': |
| 296 | if (is_object($value) || is_array($value)) { |
| 297 | $value = serialize($value); |
| 298 | } |
| 299 | return (string) $value; |
| 300 | case 'array': |
| 301 | $newArray = []; |
| 302 | if (is_array($schema->items)) { |
| 303 | foreach ($schema->items as $i => $itemSchema) { |
| 304 | $newArray[$i] = $this->coerce($value[$i], $itemSchema->type, $itemSchema); |
| 305 | } |
| 306 | } elseif (is_array($value)) { |
| 307 | foreach ($value as $i => $v) { |
| 308 | $newArray[$i] = $this->coerce($v, $schema->items->type, $schema->items); |
| 309 | } |
| 310 | } else { |
| 311 | $newArray[] = serialize($value); |
| 312 | } |
| 313 | return $newArray; |
| 314 | case 'object': |
| 315 | $newObject = []; // we handle JSON objects as assoc arrays in PHP |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 318 | continue; |
| 319 | } |
| 320 | $newObject[$propName] = $this->coerce($value[$propName], $propSchema->type, $propSchema); |
| 321 | } |
| 322 | return $newObject; |
| 323 | } |
| 324 | throw new Exception('Requested variable coercion for a type that was not recognized: ' . $type); |
| 325 | } |
| 326 | |
| 327 | /** |
| 328 | * Get the validation rules for the properties of a schema |
| 329 | * |
| 330 | * These validation rules are returned in a format that is ready to be passed |
| 331 | * into ValidatorFactory::make(). |
| 332 | * |
| 333 | * @param string $schemaName One of the SCHEMA_... constants |
| 334 | * @param array $allowedLocales List of allowed locale keys. |
| 335 | * |
| 336 | * @return array List of validation rules for each property |
| 337 | */ |
| 338 | public function getValidationRules($schemaName, $allowedLocales) |
| 339 | { |
| 340 | $schema = $this->get($schemaName); |
| 341 | |
| 342 | $rules = []; |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 344 | if (!empty($propSchema->multilingual)) { |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 346 | $rules = $this->addPropValidationRules($rules, $propName . '.' . $localeKey, $propSchema); |
| 347 | } |
| 348 | } else { |
| 349 | $rules = $this->addPropValidationRules($rules, $propName, $propSchema); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | return $rules; |
| 354 | } |
| 355 | |
| 356 | /** |
| 357 | * Compile the validation rules for a single property's schema |
| 358 | * |
| 359 | * @param object $propSchema The property schema |
| 360 | * |
| 361 | * @return array List of Laravel-formatted validation rules |
| 362 | */ |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 366 | return $rules; |
| 367 | } |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 370 | case 'integer': |
| 371 | case 'numeric': |
| 372 | case 'string': |
| 373 | $rules[$ruleKey] = [$propSchema->type]; |
| 374 | if (!empty($propSchema->validation)) { |
| 375 | $rules[$ruleKey] = array_merge($rules[$ruleKey], $propSchema->validation); |
| 376 | } |
| 377 | break; |
| 378 | case 'array': |
| 379 | if ($propSchema->items->type === 'object') { |
| 380 | $rules = $this->addPropValidationRules($rules, $ruleKey . '.*', $propSchema->items); |
| 381 | } else { |
| 382 | $rules[$ruleKey] = ['array']; |
| 383 | if (!empty($propSchema->validation)) { |
| 384 | $rules[$ruleKey] = array_merge($rules[$ruleKey], $propSchema->validation); |
| 385 | } |
| 386 | $rules[$ruleKey . '.*'] = [$propSchema->items->type]; |
| 387 | if (!empty($propSchema->items->validation)) { |
| 388 | $rules[$ruleKey . '.*'] = array_merge($rules[$ruleKey . '.*'], $propSchema->items->validation); |
| 389 | } |
| 390 | } |
| 391 | break; |
| 392 | case 'object': |
| 393 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 394 | $rules = $this->addPropValidationRules($rules, $ruleKey . '.' . $subPropName, $subPropSchema); |
| 395 | } |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 401 | |
| 402 | /** |
| 403 | * Format validation errors |
| 404 | * |
| 405 | * This method receives a (Laravel) MessageBag object and formats an error |
| 406 | * array to match the entity's schema. It converts Laravel's dot notation for |
| 407 | * objects and arrays: |
| 408 | * |
| 409 | * [ |
| 410 | * foo.en: ['Error message'], |
| 411 | * foo.fr_CA: ['Error message'], |
| 412 | * bar.0.baz: ['Error message'], |
| 413 | * ] |
| 414 | * |
| 415 | * Into an assoc array, collapsing subproperty errors into their parent prop: |
| 416 | * |
| 417 | * [ |
| 418 | * foo: [ |
| 419 | * en: ['Error message'], |
| 420 | * fr_CA: ['Error message'], |
| 421 | * ], |
| 422 | * bar: ['Error message'], |
| 423 | * ] |
| 424 | */ |
| 425 | public function formatValidationErrors(MessageBag $errorBag): array |
| 426 | { |
| 427 | $formatted = []; |
| 428 | foreach ($errorBag->getMessages() as $ruleKey => $messages) { |
| 429 | Arr::set($formatted, $ruleKey, $messages); |
| 430 | } |
| 431 | return $formatted; |
| 432 | } |
| 433 | |
| 434 | /** |
| 435 | * Set default values for an object |
| 436 | * |
| 437 | * Get default values from an object's schema and set them for the passed |
| 438 | * object. |
| 439 | * |
| 440 | * localeParams are used to populate translation strings where default values |
| 441 | * rely on them. For example, a locale string like the following: |
| 442 | * |
| 443 | * "This email was sent on behalf of {$contextName}." |
| 444 | * |
| 445 | * Will expect a $localeParams value like this: |
| 446 | * |
| 447 | * ['contextName' => 'Journal of Public Knowledge'] |
| 448 | * |
| 449 | * @param string $schemaName One of the SCHEMA_... constants |
| 450 | * @param T $object The object to be modified |
| 451 | * @param array $supportedLocales List of locale keys that should receive |
| 452 | * default content. Example: ['en', 'fr_CA'] |
| 453 | * @param string $primaryLocale Example: `en` |
| 454 | * @param array $localeParams Key/value params for the translation strings |
| 455 | * |
| 456 | * @return T |
| 457 | */ |
| 458 | public function setDefaults($schemaName, $object, $supportedLocales, $primaryLocale, $localeParams = []) |
| 459 | { |
| 460 | $schema = $this->get($schemaName); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 478 | } |
| 479 | |
| 480 | return $object; |
| 481 | } |
| 482 | |
| 483 | /** |
| 484 | * Get the default values for a specific locale |
| 485 | * |
| 486 | * @param string $schemaName One of the SCHEMA_... constants |
| 487 | * @param string $locale The locale key to get values for. Example: `en` |
| 488 | * @param array $localeParams Key/value params for the translation strings |
| 489 | * |
| 490 | * @return array Key/value of property defaults for the specified locale |
| 491 | */ |
| 492 | public function getLocaleDefaults($schemaName, $locale, $localeParams) |
| 493 | { |
| 494 | $schema = $this->get($schemaName); |
| 495 | $defaults = []; |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 498 | continue; |
| 499 | } |
| 500 | $defaults[$propName] = $this->getDefault($propSchema, $localeParams, $locale); |
| 501 | } |
| 502 | |
| 503 | return $defaults; |
| 504 | } |
| 505 | |
| 506 | /** |
| 507 | * Get a default value for a property based on the schema |
| 508 | * |
| 509 | * @param object $propSchema The schema definition for this property |
| 510 | * @param array|null $localeParams Optional. Key/value params for the translation strings |
| 511 | * @param string|null $localeKey Optional. The locale to translate into |
| 512 | * |
| 513 | * @return mixed Will return null if no default value is available |
| 514 | */ |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 523 | if (property_exists($propSchema, 'default')) { |
| 524 | return $propSchema->default; |
| 525 | } elseif (property_exists($propSchema, 'defaultLocaleKey')) { |
| 526 | return __($propSchema->defaultLocaleKey, $localeParams, $localeKey); |
| 527 | } |
| 528 | break; |
| 529 | case 'array': |
| 530 | $value = []; |
| 531 | foreach ($propSchema->default as $default) { |
| 532 | $itemSchema = $propSchema->items; |
| 533 | $itemSchema->default = $default; |
| 534 | $value[] = $this->getDefault($itemSchema, $localeParams, $localeKey); |
| 535 | } |
| 536 | return $value; |
| 537 | case 'object': |
| 538 | $value = []; |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 541 | continue; |
| 542 | } |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 550 | } else { |
| 551 | $value[$subPropName] = $defaultSubProp; |
| 552 | } |
| 553 | } |
| 554 | return $value; |
| 555 | } |
| 556 | return null; |
| 557 | } |
| 558 | |
| 559 | /** |
| 560 | * Add multilingual props for missing values |
| 561 | * |
| 562 | * This method will take a set of property values and add empty entries for |
| 563 | * any locales that are missing. Given the following: |
| 564 | * |
| 565 | * $values = [ |
| 566 | * 'title' => [ |
| 567 | * 'en' => 'The Journal of Public Knowledge', |
| 568 | * ] |
| 569 | * ] |
| 570 | * |
| 571 | * If the locales en and fr_CA are requested, it will return the following: |
| 572 | * |
| 573 | * $values = [ |
| 574 | * 'title' => [ |
| 575 | * 'en' => 'The Journal of Public Knowledge', |
| 576 | * 'fr_CA' => '', |
| 577 | * ] |
| 578 | * ] |
| 579 | * |
| 580 | * This is primarily used to ensure API responses present a consistent data |
| 581 | * structure regardless of which properties have values. |
| 582 | * |
| 583 | * @param string $schemaName One of the SCHEMA_... constants |
| 584 | * @param array $values Key/value list of entity properties |
| 585 | * |
| 586 | * @return array |
| 587 | */ |
| 588 | public function addMissingMultilingualValues($schemaName, $values, $localeKeys) |
| 589 | { |
| 590 | $schema = $this->get($schemaName); |
| 591 | $multilingualProps = $this->getMultilingualProps($schemaName); |
| 592 | |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | return $values; |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | if (!PKP_STRICT_MODE) { |
| 619 | class_alias('\PKP\services\PKPSchemaService', '\PKPSchemaService'); |
| 620 | foreach ([ |
| 621 | 'SCHEMA_ANNOUNCEMENT', |
| 622 | 'SCHEMA_AUTHOR', |
| 623 | 'SCHEMA_CONTEXT', |
| 624 | 'SCHEMA_EMAIL_TEMPLATE', |
| 625 | 'SCHEMA_GALLEY', |
| 626 | 'SCHEMA_ISSUE', |
| 627 | 'SCHEMA_PUBLICATION', |
| 628 | 'SCHEMA_REVIEW_ASSIGNMENT', |
| 629 | 'SCHEMA_REVIEW_ROUND', |
| 630 | 'SCHEMA_SECTION', |
| 631 | 'SCHEMA_SITE', |
| 632 | 'SCHEMA_SUBMISSION', |
| 633 | 'SCHEMA_SUBMISSION_FILE', |
| 634 | 'SCHEMA_USER', |
| 635 | 'SCHEMA_USER_GROUP', |
| 636 | ] as $constantName) { |
| 637 | if (!defined($constantName)) { |
| 638 | define($constantName, constant('PKPSchemaService::' . $constantName)); |
| 639 | } |
| 640 | } |
| 641 | } |
Below are the source code lines that represent each code path as identified by Xdebug. Please note a path is not
necessarily coterminous with a line, a line may contain multiple paths and therefore show up more than once.
Please also be aware that some paths may include implicit rather than explicit branches, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 588 | public function addMissingMultilingualValues($schemaName, $values, $localeKeys) |
| 589 | { |
| 590 | $schema = $this->get($schemaName); |
| 591 | $multilingualProps = $this->getMultilingualProps($schemaName); |
| 592 | |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | return $values; |
| 615 | } |
| 588 | public function addMissingMultilingualValues($schemaName, $values, $localeKeys) |
| 589 | { |
| 590 | $schema = $this->get($schemaName); |
| 591 | $multilingualProps = $this->getMultilingualProps($schemaName); |
| 592 | |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | return $values; |
| 615 | } |
| 588 | public function addMissingMultilingualValues($schemaName, $values, $localeKeys) |
| 589 | { |
| 590 | $schema = $this->get($schemaName); |
| 591 | $multilingualProps = $this->getMultilingualProps($schemaName); |
| 592 | |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 605 | case 'array': |
| 605 | case 'array': |
| 609 | $values[$key][$localeKey] = null; |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | return $values; |
| 615 | } |
| 588 | public function addMissingMultilingualValues($schemaName, $values, $localeKeys) |
| 589 | { |
| 590 | $schema = $this->get($schemaName); |
| 591 | $multilingualProps = $this->getMultilingualProps($schemaName); |
| 592 | |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | return $values; |
| 615 | } |
| 588 | public function addMissingMultilingualValues($schemaName, $values, $localeKeys) |
| 589 | { |
| 590 | $schema = $this->get($schemaName); |
| 591 | $multilingualProps = $this->getMultilingualProps($schemaName); |
| 592 | |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | return $values; |
| 615 | } |
| 588 | public function addMissingMultilingualValues($schemaName, $values, $localeKeys) |
| 589 | { |
| 590 | $schema = $this->get($schemaName); |
| 591 | $multilingualProps = $this->getMultilingualProps($schemaName); |
| 592 | |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | return $values; |
| 615 | } |
| 588 | public function addMissingMultilingualValues($schemaName, $values, $localeKeys) |
| 589 | { |
| 590 | $schema = $this->get($schemaName); |
| 591 | $multilingualProps = $this->getMultilingualProps($schemaName); |
| 592 | |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 605 | case 'array': |
| 605 | case 'array': |
| 609 | $values[$key][$localeKey] = null; |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | return $values; |
| 615 | } |
| 588 | public function addMissingMultilingualValues($schemaName, $values, $localeKeys) |
| 589 | { |
| 590 | $schema = $this->get($schemaName); |
| 591 | $multilingualProps = $this->getMultilingualProps($schemaName); |
| 592 | |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | return $values; |
| 615 | } |
| 588 | public function addMissingMultilingualValues($schemaName, $values, $localeKeys) |
| 589 | { |
| 590 | $schema = $this->get($schemaName); |
| 591 | $multilingualProps = $this->getMultilingualProps($schemaName); |
| 592 | |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | return $values; |
| 615 | } |
| 588 | public function addMissingMultilingualValues($schemaName, $values, $localeKeys) |
| 589 | { |
| 590 | $schema = $this->get($schemaName); |
| 591 | $multilingualProps = $this->getMultilingualProps($schemaName); |
| 592 | |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | return $values; |
| 615 | } |
| 588 | public function addMissingMultilingualValues($schemaName, $values, $localeKeys) |
| 589 | { |
| 590 | $schema = $this->get($schemaName); |
| 591 | $multilingualProps = $this->getMultilingualProps($schemaName); |
| 592 | |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | return $values; |
| 615 | } |
| 588 | public function addMissingMultilingualValues($schemaName, $values, $localeKeys) |
| 589 | { |
| 590 | $schema = $this->get($schemaName); |
| 591 | $multilingualProps = $this->getMultilingualProps($schemaName); |
| 592 | |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | return $values; |
| 615 | } |
| 588 | public function addMissingMultilingualValues($schemaName, $values, $localeKeys) |
| 589 | { |
| 590 | $schema = $this->get($schemaName); |
| 591 | $multilingualProps = $this->getMultilingualProps($schemaName); |
| 592 | |
| 593 | foreach ($values as $key => $value) { |
| 593 | foreach ($values as $key => $value) { |
| 594 | if (!in_array($key, $multilingualProps)) { |
| 595 | continue; |
| 596 | } |
| 597 | foreach ($localeKeys as $localeKey) { |
| 598 | if (is_array($value) && array_key_exists($localeKey, $value)) { |
| 599 | continue; |
| 600 | } |
| 601 | switch ($schema->properties->{$key}->type) { |
| 602 | case 'string': |
| 603 | $values[$key][$localeKey] = ''; |
| 604 | break; |
| 605 | case 'array': |
| 606 | $values[$key][$localeKey] = []; |
| 607 | break; |
| 608 | default: |
| 609 | $values[$key][$localeKey] = null; |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | return $values; |
| 615 | } |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 366 | return $rules; |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 370 | case 'integer': |
| 371 | case 'numeric': |
| 372 | case 'string': |
| 378 | case 'array': |
| 392 | case 'object': |
| 392 | case 'object': |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 370 | case 'integer': |
| 371 | case 'numeric': |
| 372 | case 'string': |
| 378 | case 'array': |
| 392 | case 'object': |
| 393 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 393 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 393 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 393 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 393 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 394 | $rules = $this->addPropValidationRules($rules, $ruleKey . '.' . $subPropName, $subPropSchema); |
| 395 | } |
| 396 | break; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 370 | case 'integer': |
| 371 | case 'numeric': |
| 372 | case 'string': |
| 378 | case 'array': |
| 392 | case 'object': |
| 393 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 393 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 393 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 394 | $rules = $this->addPropValidationRules($rules, $ruleKey . '.' . $subPropName, $subPropSchema); |
| 395 | } |
| 396 | break; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 370 | case 'integer': |
| 371 | case 'numeric': |
| 372 | case 'string': |
| 378 | case 'array': |
| 392 | case 'object': |
| 393 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 393 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 394 | $rules = $this->addPropValidationRules($rules, $ruleKey . '.' . $subPropName, $subPropSchema); |
| 395 | } |
| 396 | break; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 370 | case 'integer': |
| 371 | case 'numeric': |
| 372 | case 'string': |
| 378 | case 'array': |
| 379 | if ($propSchema->items->type === 'object') { |
| 379 | if ($propSchema->items->type === 'object') { |
| 380 | $rules = $this->addPropValidationRules($rules, $ruleKey . '.*', $propSchema->items); |
| 391 | break; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 370 | case 'integer': |
| 371 | case 'numeric': |
| 372 | case 'string': |
| 378 | case 'array': |
| 379 | if ($propSchema->items->type === 'object') { |
| 382 | $rules[$ruleKey] = ['array']; |
| 383 | if (!empty($propSchema->validation)) { |
| 384 | $rules[$ruleKey] = array_merge($rules[$ruleKey], $propSchema->validation); |
| 385 | } |
| 386 | $rules[$ruleKey . '.*'] = [$propSchema->items->type]; |
| 386 | $rules[$ruleKey . '.*'] = [$propSchema->items->type]; |
| 387 | if (!empty($propSchema->items->validation)) { |
| 388 | $rules[$ruleKey . '.*'] = array_merge($rules[$ruleKey . '.*'], $propSchema->items->validation); |
| 389 | } |
| 390 | } |
| 391 | break; |
| 391 | break; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 370 | case 'integer': |
| 371 | case 'numeric': |
| 372 | case 'string': |
| 378 | case 'array': |
| 379 | if ($propSchema->items->type === 'object') { |
| 382 | $rules[$ruleKey] = ['array']; |
| 383 | if (!empty($propSchema->validation)) { |
| 384 | $rules[$ruleKey] = array_merge($rules[$ruleKey], $propSchema->validation); |
| 385 | } |
| 386 | $rules[$ruleKey . '.*'] = [$propSchema->items->type]; |
| 386 | $rules[$ruleKey . '.*'] = [$propSchema->items->type]; |
| 387 | if (!empty($propSchema->items->validation)) { |
| 391 | break; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 370 | case 'integer': |
| 371 | case 'numeric': |
| 372 | case 'string': |
| 378 | case 'array': |
| 379 | if ($propSchema->items->type === 'object') { |
| 382 | $rules[$ruleKey] = ['array']; |
| 383 | if (!empty($propSchema->validation)) { |
| 386 | $rules[$ruleKey . '.*'] = [$propSchema->items->type]; |
| 387 | if (!empty($propSchema->items->validation)) { |
| 388 | $rules[$ruleKey . '.*'] = array_merge($rules[$ruleKey . '.*'], $propSchema->items->validation); |
| 389 | } |
| 390 | } |
| 391 | break; |
| 391 | break; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 370 | case 'integer': |
| 371 | case 'numeric': |
| 372 | case 'string': |
| 378 | case 'array': |
| 379 | if ($propSchema->items->type === 'object') { |
| 382 | $rules[$ruleKey] = ['array']; |
| 383 | if (!empty($propSchema->validation)) { |
| 386 | $rules[$ruleKey . '.*'] = [$propSchema->items->type]; |
| 387 | if (!empty($propSchema->items->validation)) { |
| 391 | break; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 370 | case 'integer': |
| 371 | case 'numeric': |
| 372 | case 'string': |
| 373 | $rules[$ruleKey] = [$propSchema->type]; |
| 374 | if (!empty($propSchema->validation)) { |
| 375 | $rules[$ruleKey] = array_merge($rules[$ruleKey], $propSchema->validation); |
| 376 | } |
| 377 | break; |
| 377 | break; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 370 | case 'integer': |
| 371 | case 'numeric': |
| 372 | case 'string': |
| 373 | $rules[$ruleKey] = [$propSchema->type]; |
| 374 | if (!empty($propSchema->validation)) { |
| 377 | break; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 370 | case 'integer': |
| 371 | case 'numeric': |
| 373 | $rules[$ruleKey] = [$propSchema->type]; |
| 374 | if (!empty($propSchema->validation)) { |
| 375 | $rules[$ruleKey] = array_merge($rules[$ruleKey], $propSchema->validation); |
| 376 | } |
| 377 | break; |
| 377 | break; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 370 | case 'integer': |
| 371 | case 'numeric': |
| 373 | $rules[$ruleKey] = [$propSchema->type]; |
| 374 | if (!empty($propSchema->validation)) { |
| 377 | break; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 370 | case 'integer': |
| 373 | $rules[$ruleKey] = [$propSchema->type]; |
| 374 | if (!empty($propSchema->validation)) { |
| 375 | $rules[$ruleKey] = array_merge($rules[$ruleKey], $propSchema->validation); |
| 376 | } |
| 377 | break; |
| 377 | break; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 370 | case 'integer': |
| 373 | $rules[$ruleKey] = [$propSchema->type]; |
| 374 | if (!empty($propSchema->validation)) { |
| 377 | break; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 373 | $rules[$ruleKey] = [$propSchema->type]; |
| 374 | if (!empty($propSchema->validation)) { |
| 375 | $rules[$ruleKey] = array_merge($rules[$ruleKey], $propSchema->validation); |
| 376 | } |
| 377 | break; |
| 377 | break; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 363 | public function addPropValidationRules($rules, $ruleKey, $propSchema) |
| 364 | { |
| 365 | if (!empty($propSchema->readOnly)) { |
| 368 | switch ($propSchema->type) { |
| 369 | case 'boolean': |
| 373 | $rules[$ruleKey] = [$propSchema->type]; |
| 374 | if (!empty($propSchema->validation)) { |
| 377 | break; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return $rules; |
| 400 | } |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 286 | return $value; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 300 | case 'array': |
| 314 | case 'object': |
| 314 | case 'object': |
| 324 | throw new Exception('Requested variable coercion for a type that was not recognized: ' . $type); |
| 325 | } |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 300 | case 'array': |
| 314 | case 'object': |
| 315 | $newObject = []; // we handle JSON objects as assoc arrays in PHP |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 318 | continue; |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 318 | continue; |
| 319 | } |
| 320 | $newObject[$propName] = $this->coerce($value[$propName], $propSchema->type, $propSchema); |
| 321 | } |
| 322 | return $newObject; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 300 | case 'array': |
| 314 | case 'object': |
| 315 | $newObject = []; // we handle JSON objects as assoc arrays in PHP |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 318 | continue; |
| 319 | } |
| 320 | $newObject[$propName] = $this->coerce($value[$propName], $propSchema->type, $propSchema); |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 318 | continue; |
| 319 | } |
| 320 | $newObject[$propName] = $this->coerce($value[$propName], $propSchema->type, $propSchema); |
| 321 | } |
| 322 | return $newObject; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 300 | case 'array': |
| 314 | case 'object': |
| 315 | $newObject = []; // we handle JSON objects as assoc arrays in PHP |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 318 | continue; |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 318 | continue; |
| 319 | } |
| 320 | $newObject[$propName] = $this->coerce($value[$propName], $propSchema->type, $propSchema); |
| 321 | } |
| 322 | return $newObject; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 300 | case 'array': |
| 314 | case 'object': |
| 315 | $newObject = []; // we handle JSON objects as assoc arrays in PHP |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 318 | continue; |
| 319 | } |
| 320 | $newObject[$propName] = $this->coerce($value[$propName], $propSchema->type, $propSchema); |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 318 | continue; |
| 319 | } |
| 320 | $newObject[$propName] = $this->coerce($value[$propName], $propSchema->type, $propSchema); |
| 321 | } |
| 322 | return $newObject; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 300 | case 'array': |
| 314 | case 'object': |
| 315 | $newObject = []; // we handle JSON objects as assoc arrays in PHP |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 318 | continue; |
| 319 | } |
| 320 | $newObject[$propName] = $this->coerce($value[$propName], $propSchema->type, $propSchema); |
| 321 | } |
| 322 | return $newObject; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 300 | case 'array': |
| 314 | case 'object': |
| 315 | $newObject = []; // we handle JSON objects as assoc arrays in PHP |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 316 | foreach ($schema->properties as $propName => $propSchema) { |
| 317 | if (!isset($value[$propName]) || !empty($propSchema->readOnly)) { |
| 318 | continue; |
| 319 | } |
| 320 | $newObject[$propName] = $this->coerce($value[$propName], $propSchema->type, $propSchema); |
| 321 | } |
| 322 | return $newObject; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 300 | case 'array': |
| 301 | $newArray = []; |
| 302 | if (is_array($schema->items)) { |
| 303 | foreach ($schema->items as $i => $itemSchema) { |
| 303 | foreach ($schema->items as $i => $itemSchema) { |
| 303 | foreach ($schema->items as $i => $itemSchema) { |
| 303 | foreach ($schema->items as $i => $itemSchema) { |
| 302 | if (is_array($schema->items)) { |
| 303 | foreach ($schema->items as $i => $itemSchema) { |
| 313 | return $newArray; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 300 | case 'array': |
| 301 | $newArray = []; |
| 302 | if (is_array($schema->items)) { |
| 303 | foreach ($schema->items as $i => $itemSchema) { |
| 303 | foreach ($schema->items as $i => $itemSchema) { |
| 302 | if (is_array($schema->items)) { |
| 303 | foreach ($schema->items as $i => $itemSchema) { |
| 313 | return $newArray; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 300 | case 'array': |
| 301 | $newArray = []; |
| 302 | if (is_array($schema->items)) { |
| 303 | foreach ($schema->items as $i => $itemSchema) { |
| 302 | if (is_array($schema->items)) { |
| 303 | foreach ($schema->items as $i => $itemSchema) { |
| 313 | return $newArray; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 300 | case 'array': |
| 301 | $newArray = []; |
| 302 | if (is_array($schema->items)) { |
| 306 | } elseif (is_array($value)) { |
| 307 | foreach ($value as $i => $v) { |
| 307 | foreach ($value as $i => $v) { |
| 307 | foreach ($value as $i => $v) { |
| 307 | foreach ($value as $i => $v) { |
| 306 | } elseif (is_array($value)) { |
| 307 | foreach ($value as $i => $v) { |
| 313 | return $newArray; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 300 | case 'array': |
| 301 | $newArray = []; |
| 302 | if (is_array($schema->items)) { |
| 306 | } elseif (is_array($value)) { |
| 307 | foreach ($value as $i => $v) { |
| 307 | foreach ($value as $i => $v) { |
| 306 | } elseif (is_array($value)) { |
| 307 | foreach ($value as $i => $v) { |
| 313 | return $newArray; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 300 | case 'array': |
| 301 | $newArray = []; |
| 302 | if (is_array($schema->items)) { |
| 306 | } elseif (is_array($value)) { |
| 307 | foreach ($value as $i => $v) { |
| 306 | } elseif (is_array($value)) { |
| 307 | foreach ($value as $i => $v) { |
| 313 | return $newArray; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 300 | case 'array': |
| 301 | $newArray = []; |
| 302 | if (is_array($schema->items)) { |
| 306 | } elseif (is_array($value)) { |
| 311 | $newArray[] = serialize($value); |
| 312 | } |
| 313 | return $newArray; |
| 313 | return $newArray; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 296 | if (is_object($value) || is_array($value)) { |
| 296 | if (is_object($value) || is_array($value)) { |
| 296 | if (is_object($value) || is_array($value)) { |
| 297 | $value = serialize($value); |
| 298 | } |
| 299 | return (string) $value; |
| 299 | return (string) $value; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 296 | if (is_object($value) || is_array($value)) { |
| 296 | if (is_object($value) || is_array($value)) { |
| 296 | if (is_object($value) || is_array($value)) { |
| 299 | return (string) $value; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 296 | if (is_object($value) || is_array($value)) { |
| 296 | if (is_object($value) || is_array($value)) { |
| 297 | $value = serialize($value); |
| 298 | } |
| 299 | return (string) $value; |
| 299 | return (string) $value; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 295 | case 'string': |
| 296 | if (is_object($value) || is_array($value)) { |
| 296 | if (is_object($value) || is_array($value)) { |
| 299 | return (string) $value; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 293 | case 'number': |
| 294 | return (float) $value; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 291 | case 'integer': |
| 292 | return (int) $value; |
| 283 | public function coerce($value, $type, $schema) |
| 284 | { |
| 285 | if (is_null($value)) { |
| 289 | case 'boolean': |
| 290 | return (bool) $value; |
| 425 | public function formatValidationErrors(MessageBag $errorBag): array |
| 426 | { |
| 427 | $formatted = []; |
| 428 | foreach ($errorBag->getMessages() as $ruleKey => $messages) { |
| 428 | foreach ($errorBag->getMessages() as $ruleKey => $messages) { |
| 428 | foreach ($errorBag->getMessages() as $ruleKey => $messages) { |
| 428 | foreach ($errorBag->getMessages() as $ruleKey => $messages) { |
| 428 | foreach ($errorBag->getMessages() as $ruleKey => $messages) { |
| 429 | Arr::set($formatted, $ruleKey, $messages); |
| 430 | } |
| 431 | return $formatted; |
| 432 | } |
| 425 | public function formatValidationErrors(MessageBag $errorBag): array |
| 426 | { |
| 427 | $formatted = []; |
| 428 | foreach ($errorBag->getMessages() as $ruleKey => $messages) { |
| 428 | foreach ($errorBag->getMessages() as $ruleKey => $messages) { |
| 428 | foreach ($errorBag->getMessages() as $ruleKey => $messages) { |
| 429 | Arr::set($formatted, $ruleKey, $messages); |
| 430 | } |
| 431 | return $formatted; |
| 432 | } |
| 425 | public function formatValidationErrors(MessageBag $errorBag): array |
| 426 | { |
| 427 | $formatted = []; |
| 428 | foreach ($errorBag->getMessages() as $ruleKey => $messages) { |
| 428 | foreach ($errorBag->getMessages() as $ruleKey => $messages) { |
| 429 | Arr::set($formatted, $ruleKey, $messages); |
| 430 | } |
| 431 | return $formatted; |
| 432 | } |
| 71 | public function get($schemaName, $forceReload = false) |
| 72 | { |
| 73 | Hook::run('Schema::get::before::' . $schemaName, [&$forceReload]); |
| 74 | |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 76 | return $this->_schemas[$schemaName]; |
| 71 | public function get($schemaName, $forceReload = false) |
| 72 | { |
| 73 | Hook::run('Schema::get::before::' . $schemaName, [&$forceReload]); |
| 74 | |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 79 | $schemaFile = sprintf('%s/lib/pkp/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 80 | if (file_exists($schemaFile)) { |
| 81 | $schema = json_decode(file_get_contents($schemaFile)); |
| 82 | if (!$schema) { |
| 83 | throw new Exception('Schema failed to decode. This usually means it is invalid JSON. Requested: ' . $schemaFile . '. Last JSON error: ' . json_last_error()); |
| 71 | public function get($schemaName, $forceReload = false) |
| 72 | { |
| 73 | Hook::run('Schema::get::before::' . $schemaName, [&$forceReload]); |
| 74 | |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 79 | $schemaFile = sprintf('%s/lib/pkp/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 80 | if (file_exists($schemaFile)) { |
| 81 | $schema = json_decode(file_get_contents($schemaFile)); |
| 82 | if (!$schema) { |
| 80 | if (file_exists($schemaFile)) { |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 92 | if (file_exists($appSchemaFile)) { |
| 93 | $appSchema = json_decode(file_get_contents($appSchemaFile)); |
| 94 | if (!$appSchema) { |
| 95 | throw new Exception('Schema failed to decode. This usually means it is invalid JSON. Requested: ' . $appSchemaFile . '. Last JSON error: ' . json_last_error()); |
| 71 | public function get($schemaName, $forceReload = false) |
| 72 | { |
| 73 | Hook::run('Schema::get::before::' . $schemaName, [&$forceReload]); |
| 74 | |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 79 | $schemaFile = sprintf('%s/lib/pkp/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 80 | if (file_exists($schemaFile)) { |
| 81 | $schema = json_decode(file_get_contents($schemaFile)); |
| 82 | if (!$schema) { |
| 80 | if (file_exists($schemaFile)) { |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 92 | if (file_exists($appSchemaFile)) { |
| 93 | $appSchema = json_decode(file_get_contents($appSchemaFile)); |
| 94 | if (!$appSchema) { |
| 97 | $schema = $this->merge($schema, $appSchema); |
| 98 | } |
| 99 | |
| 100 | Hook::call('Schema::get::' . $schemaName, [&$schema]); |
| 100 | Hook::call('Schema::get::' . $schemaName, [&$schema]); |
| 101 | |
| 102 | $this->_schemas[$schemaName] = $schema; |
| 103 | |
| 104 | return $schema; |
| 105 | } |
| 71 | public function get($schemaName, $forceReload = false) |
| 72 | { |
| 73 | Hook::run('Schema::get::before::' . $schemaName, [&$forceReload]); |
| 74 | |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 79 | $schemaFile = sprintf('%s/lib/pkp/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 80 | if (file_exists($schemaFile)) { |
| 81 | $schema = json_decode(file_get_contents($schemaFile)); |
| 82 | if (!$schema) { |
| 80 | if (file_exists($schemaFile)) { |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 92 | if (file_exists($appSchemaFile)) { |
| 100 | Hook::call('Schema::get::' . $schemaName, [&$schema]); |
| 101 | |
| 102 | $this->_schemas[$schemaName] = $schema; |
| 103 | |
| 104 | return $schema; |
| 105 | } |
| 71 | public function get($schemaName, $forceReload = false) |
| 72 | { |
| 73 | Hook::run('Schema::get::before::' . $schemaName, [&$forceReload]); |
| 74 | |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 79 | $schemaFile = sprintf('%s/lib/pkp/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 80 | if (file_exists($schemaFile)) { |
| 87 | $schema = new \stdClass(); |
| 88 | } |
| 89 | |
| 90 | // Merge an app-specific schema file if it exists |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 92 | if (file_exists($appSchemaFile)) { |
| 93 | $appSchema = json_decode(file_get_contents($appSchemaFile)); |
| 94 | if (!$appSchema) { |
| 95 | throw new Exception('Schema failed to decode. This usually means it is invalid JSON. Requested: ' . $appSchemaFile . '. Last JSON error: ' . json_last_error()); |
| 71 | public function get($schemaName, $forceReload = false) |
| 72 | { |
| 73 | Hook::run('Schema::get::before::' . $schemaName, [&$forceReload]); |
| 74 | |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 79 | $schemaFile = sprintf('%s/lib/pkp/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 80 | if (file_exists($schemaFile)) { |
| 87 | $schema = new \stdClass(); |
| 88 | } |
| 89 | |
| 90 | // Merge an app-specific schema file if it exists |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 92 | if (file_exists($appSchemaFile)) { |
| 93 | $appSchema = json_decode(file_get_contents($appSchemaFile)); |
| 94 | if (!$appSchema) { |
| 97 | $schema = $this->merge($schema, $appSchema); |
| 98 | } |
| 99 | |
| 100 | Hook::call('Schema::get::' . $schemaName, [&$schema]); |
| 100 | Hook::call('Schema::get::' . $schemaName, [&$schema]); |
| 101 | |
| 102 | $this->_schemas[$schemaName] = $schema; |
| 103 | |
| 104 | return $schema; |
| 105 | } |
| 71 | public function get($schemaName, $forceReload = false) |
| 72 | { |
| 73 | Hook::run('Schema::get::before::' . $schemaName, [&$forceReload]); |
| 74 | |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 79 | $schemaFile = sprintf('%s/lib/pkp/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 80 | if (file_exists($schemaFile)) { |
| 87 | $schema = new \stdClass(); |
| 88 | } |
| 89 | |
| 90 | // Merge an app-specific schema file if it exists |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 92 | if (file_exists($appSchemaFile)) { |
| 100 | Hook::call('Schema::get::' . $schemaName, [&$schema]); |
| 101 | |
| 102 | $this->_schemas[$schemaName] = $schema; |
| 103 | |
| 104 | return $schema; |
| 105 | } |
| 71 | public function get($schemaName, $forceReload = false) |
| 72 | { |
| 73 | Hook::run('Schema::get::before::' . $schemaName, [&$forceReload]); |
| 74 | |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 76 | return $this->_schemas[$schemaName]; |
| 71 | public function get($schemaName, $forceReload = false) |
| 72 | { |
| 73 | Hook::run('Schema::get::before::' . $schemaName, [&$forceReload]); |
| 74 | |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 79 | $schemaFile = sprintf('%s/lib/pkp/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 80 | if (file_exists($schemaFile)) { |
| 81 | $schema = json_decode(file_get_contents($schemaFile)); |
| 82 | if (!$schema) { |
| 83 | throw new Exception('Schema failed to decode. This usually means it is invalid JSON. Requested: ' . $schemaFile . '. Last JSON error: ' . json_last_error()); |
| 71 | public function get($schemaName, $forceReload = false) |
| 72 | { |
| 73 | Hook::run('Schema::get::before::' . $schemaName, [&$forceReload]); |
| 74 | |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 79 | $schemaFile = sprintf('%s/lib/pkp/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 80 | if (file_exists($schemaFile)) { |
| 81 | $schema = json_decode(file_get_contents($schemaFile)); |
| 82 | if (!$schema) { |
| 80 | if (file_exists($schemaFile)) { |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 92 | if (file_exists($appSchemaFile)) { |
| 93 | $appSchema = json_decode(file_get_contents($appSchemaFile)); |
| 94 | if (!$appSchema) { |
| 95 | throw new Exception('Schema failed to decode. This usually means it is invalid JSON. Requested: ' . $appSchemaFile . '. Last JSON error: ' . json_last_error()); |
| 71 | public function get($schemaName, $forceReload = false) |
| 72 | { |
| 73 | Hook::run('Schema::get::before::' . $schemaName, [&$forceReload]); |
| 74 | |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 79 | $schemaFile = sprintf('%s/lib/pkp/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 80 | if (file_exists($schemaFile)) { |
| 81 | $schema = json_decode(file_get_contents($schemaFile)); |
| 82 | if (!$schema) { |
| 80 | if (file_exists($schemaFile)) { |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 92 | if (file_exists($appSchemaFile)) { |
| 93 | $appSchema = json_decode(file_get_contents($appSchemaFile)); |
| 94 | if (!$appSchema) { |
| 97 | $schema = $this->merge($schema, $appSchema); |
| 98 | } |
| 99 | |
| 100 | Hook::call('Schema::get::' . $schemaName, [&$schema]); |
| 100 | Hook::call('Schema::get::' . $schemaName, [&$schema]); |
| 101 | |
| 102 | $this->_schemas[$schemaName] = $schema; |
| 103 | |
| 104 | return $schema; |
| 105 | } |
| 71 | public function get($schemaName, $forceReload = false) |
| 72 | { |
| 73 | Hook::run('Schema::get::before::' . $schemaName, [&$forceReload]); |
| 74 | |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 79 | $schemaFile = sprintf('%s/lib/pkp/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 80 | if (file_exists($schemaFile)) { |
| 81 | $schema = json_decode(file_get_contents($schemaFile)); |
| 82 | if (!$schema) { |
| 80 | if (file_exists($schemaFile)) { |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 92 | if (file_exists($appSchemaFile)) { |
| 100 | Hook::call('Schema::get::' . $schemaName, [&$schema]); |
| 101 | |
| 102 | $this->_schemas[$schemaName] = $schema; |
| 103 | |
| 104 | return $schema; |
| 105 | } |
| 71 | public function get($schemaName, $forceReload = false) |
| 72 | { |
| 73 | Hook::run('Schema::get::before::' . $schemaName, [&$forceReload]); |
| 74 | |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 79 | $schemaFile = sprintf('%s/lib/pkp/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 80 | if (file_exists($schemaFile)) { |
| 87 | $schema = new \stdClass(); |
| 88 | } |
| 89 | |
| 90 | // Merge an app-specific schema file if it exists |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 92 | if (file_exists($appSchemaFile)) { |
| 93 | $appSchema = json_decode(file_get_contents($appSchemaFile)); |
| 94 | if (!$appSchema) { |
| 95 | throw new Exception('Schema failed to decode. This usually means it is invalid JSON. Requested: ' . $appSchemaFile . '. Last JSON error: ' . json_last_error()); |
| 71 | public function get($schemaName, $forceReload = false) |
| 72 | { |
| 73 | Hook::run('Schema::get::before::' . $schemaName, [&$forceReload]); |
| 74 | |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 79 | $schemaFile = sprintf('%s/lib/pkp/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 80 | if (file_exists($schemaFile)) { |
| 87 | $schema = new \stdClass(); |
| 88 | } |
| 89 | |
| 90 | // Merge an app-specific schema file if it exists |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 92 | if (file_exists($appSchemaFile)) { |
| 93 | $appSchema = json_decode(file_get_contents($appSchemaFile)); |
| 94 | if (!$appSchema) { |
| 97 | $schema = $this->merge($schema, $appSchema); |
| 98 | } |
| 99 | |
| 100 | Hook::call('Schema::get::' . $schemaName, [&$schema]); |
| 100 | Hook::call('Schema::get::' . $schemaName, [&$schema]); |
| 101 | |
| 102 | $this->_schemas[$schemaName] = $schema; |
| 103 | |
| 104 | return $schema; |
| 105 | } |
| 71 | public function get($schemaName, $forceReload = false) |
| 72 | { |
| 73 | Hook::run('Schema::get::before::' . $schemaName, [&$forceReload]); |
| 74 | |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 75 | if (!$forceReload && array_key_exists($schemaName, $this->_schemas)) { |
| 79 | $schemaFile = sprintf('%s/lib/pkp/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 80 | if (file_exists($schemaFile)) { |
| 87 | $schema = new \stdClass(); |
| 88 | } |
| 89 | |
| 90 | // Merge an app-specific schema file if it exists |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 91 | $appSchemaFile = sprintf('%s/schemas/%s.json', BASE_SYS_DIR, $schemaName); |
| 92 | if (file_exists($appSchemaFile)) { |
| 100 | Hook::call('Schema::get::' . $schemaName, [&$schema]); |
| 101 | |
| 102 | $this->_schemas[$schemaName] = $schema; |
| 103 | |
| 104 | return $schema; |
| 105 | } |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 529 | case 'array': |
| 537 | case 'object': |
| 537 | case 'object': |
| 554 | return $value; |
| 555 | } |
| 556 | return null; |
| 557 | } |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 529 | case 'array': |
| 537 | case 'object': |
| 538 | $value = []; |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 541 | continue; |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 541 | continue; |
| 542 | } |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 550 | } else { |
| 551 | $value[$subPropName] = $defaultSubProp; |
| 552 | } |
| 553 | } |
| 554 | return $value; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 529 | case 'array': |
| 537 | case 'object': |
| 538 | $value = []; |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 541 | continue; |
| 542 | } |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 550 | } else { |
| 551 | $value[$subPropName] = $defaultSubProp; |
| 552 | } |
| 553 | } |
| 554 | return $value; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 529 | case 'array': |
| 537 | case 'object': |
| 538 | $value = []; |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 541 | continue; |
| 542 | } |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 550 | } else { |
| 551 | $value[$subPropName] = $defaultSubProp; |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 541 | continue; |
| 542 | } |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 550 | } else { |
| 551 | $value[$subPropName] = $defaultSubProp; |
| 552 | } |
| 553 | } |
| 554 | return $value; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 529 | case 'array': |
| 537 | case 'object': |
| 538 | $value = []; |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 541 | continue; |
| 542 | } |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 550 | } else { |
| 551 | $value[$subPropName] = $defaultSubProp; |
| 552 | } |
| 553 | } |
| 554 | return $value; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 529 | case 'array': |
| 537 | case 'object': |
| 538 | $value = []; |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 541 | continue; |
| 542 | } |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 550 | } else { |
| 551 | $value[$subPropName] = $defaultSubProp; |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 541 | continue; |
| 542 | } |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 550 | } else { |
| 551 | $value[$subPropName] = $defaultSubProp; |
| 552 | } |
| 553 | } |
| 554 | return $value; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 529 | case 'array': |
| 537 | case 'object': |
| 538 | $value = []; |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 541 | continue; |
| 542 | } |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 550 | } else { |
| 551 | $value[$subPropName] = $defaultSubProp; |
| 552 | } |
| 553 | } |
| 554 | return $value; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 529 | case 'array': |
| 537 | case 'object': |
| 538 | $value = []; |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 541 | continue; |
| 542 | } |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 550 | } else { |
| 551 | $value[$subPropName] = $defaultSubProp; |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 541 | continue; |
| 542 | } |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 550 | } else { |
| 551 | $value[$subPropName] = $defaultSubProp; |
| 552 | } |
| 553 | } |
| 554 | return $value; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 529 | case 'array': |
| 537 | case 'object': |
| 538 | $value = []; |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 541 | continue; |
| 542 | } |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 550 | } else { |
| 551 | $value[$subPropName] = $defaultSubProp; |
| 552 | } |
| 553 | } |
| 554 | return $value; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 529 | case 'array': |
| 537 | case 'object': |
| 538 | $value = []; |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 541 | continue; |
| 542 | } |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 550 | } else { |
| 551 | $value[$subPropName] = $defaultSubProp; |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 541 | continue; |
| 542 | } |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 550 | } else { |
| 551 | $value[$subPropName] = $defaultSubProp; |
| 552 | } |
| 553 | } |
| 554 | return $value; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 529 | case 'array': |
| 537 | case 'object': |
| 538 | $value = []; |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 541 | continue; |
| 542 | } |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 550 | } else { |
| 551 | $value[$subPropName] = $defaultSubProp; |
| 552 | } |
| 553 | } |
| 554 | return $value; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 529 | case 'array': |
| 537 | case 'object': |
| 538 | $value = []; |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 539 | foreach ($propSchema->properties ?? [] as $subPropName => $subPropSchema) { |
| 540 | if (!property_exists($propSchema->default, $subPropName)) { |
| 541 | continue; |
| 542 | } |
| 543 | $defaultSubProp = $propSchema->default->{$subPropName}; |
| 544 | // If a prop is expected to be a string but the default value is an |
| 545 | // object with a `defaultLocaleKey` property, then we render that |
| 546 | // translation. Otherwise, we assign the values as-is and do not |
| 547 | // recursively check for nested objects/arrays inside of objects. |
| 548 | if ($subPropSchema->type === 'string' && is_object($defaultSubProp) && property_exists($defaultSubProp, 'defaultLocaleKey')) { |
| 549 | $value[$subPropName] = __($defaultSubProp->defaultLocaleKey, $localeParams, $localeKey); |
| 550 | } else { |
| 551 | $value[$subPropName] = $defaultSubProp; |
| 552 | } |
| 553 | } |
| 554 | return $value; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 529 | case 'array': |
| 530 | $value = []; |
| 531 | foreach ($propSchema->default as $default) { |
| 531 | foreach ($propSchema->default as $default) { |
| 531 | foreach ($propSchema->default as $default) { |
| 532 | $itemSchema = $propSchema->items; |
| 531 | foreach ($propSchema->default as $default) { |
| 531 | foreach ($propSchema->default as $default) { |
| 532 | $itemSchema = $propSchema->items; |
| 533 | $itemSchema->default = $default; |
| 534 | $value[] = $this->getDefault($itemSchema, $localeParams, $localeKey); |
| 535 | } |
| 536 | return $value; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 529 | case 'array': |
| 530 | $value = []; |
| 531 | foreach ($propSchema->default as $default) { |
| 531 | foreach ($propSchema->default as $default) { |
| 531 | foreach ($propSchema->default as $default) { |
| 532 | $itemSchema = $propSchema->items; |
| 533 | $itemSchema->default = $default; |
| 534 | $value[] = $this->getDefault($itemSchema, $localeParams, $localeKey); |
| 535 | } |
| 536 | return $value; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 529 | case 'array': |
| 530 | $value = []; |
| 531 | foreach ($propSchema->default as $default) { |
| 531 | foreach ($propSchema->default as $default) { |
| 532 | $itemSchema = $propSchema->items; |
| 533 | $itemSchema->default = $default; |
| 534 | $value[] = $this->getDefault($itemSchema, $localeParams, $localeKey); |
| 535 | } |
| 536 | return $value; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 523 | if (property_exists($propSchema, 'default')) { |
| 524 | return $propSchema->default; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 523 | if (property_exists($propSchema, 'default')) { |
| 525 | } elseif (property_exists($propSchema, 'defaultLocaleKey')) { |
| 526 | return __($propSchema->defaultLocaleKey, $localeParams, $localeKey); |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 522 | case 'string': |
| 523 | if (property_exists($propSchema, 'default')) { |
| 525 | } elseif (property_exists($propSchema, 'defaultLocaleKey')) { |
| 528 | break; |
| 554 | return $value; |
| 555 | } |
| 556 | return null; |
| 557 | } |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 523 | if (property_exists($propSchema, 'default')) { |
| 524 | return $propSchema->default; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 523 | if (property_exists($propSchema, 'default')) { |
| 525 | } elseif (property_exists($propSchema, 'defaultLocaleKey')) { |
| 526 | return __($propSchema->defaultLocaleKey, $localeParams, $localeKey); |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 521 | case 'number': |
| 523 | if (property_exists($propSchema, 'default')) { |
| 525 | } elseif (property_exists($propSchema, 'defaultLocaleKey')) { |
| 528 | break; |
| 554 | return $value; |
| 555 | } |
| 556 | return null; |
| 557 | } |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 523 | if (property_exists($propSchema, 'default')) { |
| 524 | return $propSchema->default; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 523 | if (property_exists($propSchema, 'default')) { |
| 525 | } elseif (property_exists($propSchema, 'defaultLocaleKey')) { |
| 526 | return __($propSchema->defaultLocaleKey, $localeParams, $localeKey); |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 520 | case 'integer': |
| 523 | if (property_exists($propSchema, 'default')) { |
| 525 | } elseif (property_exists($propSchema, 'defaultLocaleKey')) { |
| 528 | break; |
| 554 | return $value; |
| 555 | } |
| 556 | return null; |
| 557 | } |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 523 | if (property_exists($propSchema, 'default')) { |
| 524 | return $propSchema->default; |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 523 | if (property_exists($propSchema, 'default')) { |
| 525 | } elseif (property_exists($propSchema, 'defaultLocaleKey')) { |
| 526 | return __($propSchema->defaultLocaleKey, $localeParams, $localeKey); |
| 515 | public function getDefault($propSchema, $localeParams = null, $localeKey = null) |
| 516 | { |
| 517 | $localeParams ??= []; |
| 518 | switch ($propSchema->type) { |
| 519 | case 'boolean': |
| 523 | if (property_exists($propSchema, 'default')) { |
| 525 | } elseif (property_exists($propSchema, 'defaultLocaleKey')) { |
| 528 | break; |
| 554 | return $value; |
| 555 | } |
| 556 | return null; |
| 557 | } |
| 182 | public function getFullProps($schemaName) |
| 183 | { |
| 184 | $schema = $this->get($schemaName); |
| 185 | |
| 186 | $propNames = []; |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 188 | if (empty($propSchema->writeOnly)) { |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 188 | if (empty($propSchema->writeOnly)) { |
| 189 | $propNames[] = $propName; |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 188 | if (empty($propSchema->writeOnly)) { |
| 189 | $propNames[] = $propName; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | return $propNames; |
| 194 | } |
| 182 | public function getFullProps($schemaName) |
| 183 | { |
| 184 | $schema = $this->get($schemaName); |
| 185 | |
| 186 | $propNames = []; |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 188 | if (empty($propSchema->writeOnly)) { |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 188 | if (empty($propSchema->writeOnly)) { |
| 189 | $propNames[] = $propName; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | return $propNames; |
| 194 | } |
| 182 | public function getFullProps($schemaName) |
| 183 | { |
| 184 | $schema = $this->get($schemaName); |
| 185 | |
| 186 | $propNames = []; |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 188 | if (empty($propSchema->writeOnly)) { |
| 189 | $propNames[] = $propName; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | return $propNames; |
| 194 | } |
| 182 | public function getFullProps($schemaName) |
| 183 | { |
| 184 | $schema = $this->get($schemaName); |
| 185 | |
| 186 | $propNames = []; |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 187 | foreach ($schema->properties as $propName => $propSchema) { |
| 188 | if (empty($propSchema->writeOnly)) { |
| 189 | $propNames[] = $propName; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | return $propNames; |
| 194 | } |
| 492 | public function getLocaleDefaults($schemaName, $locale, $localeParams) |
| 493 | { |
| 494 | $schema = $this->get($schemaName); |
| 495 | $defaults = []; |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 498 | continue; |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 498 | continue; |
| 499 | } |
| 500 | $defaults[$propName] = $this->getDefault($propSchema, $localeParams, $locale); |
| 501 | } |
| 502 | |
| 503 | return $defaults; |
| 504 | } |
| 492 | public function getLocaleDefaults($schemaName, $locale, $localeParams) |
| 493 | { |
| 494 | $schema = $this->get($schemaName); |
| 495 | $defaults = []; |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 498 | continue; |
| 499 | } |
| 500 | $defaults[$propName] = $this->getDefault($propSchema, $localeParams, $locale); |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 498 | continue; |
| 499 | } |
| 500 | $defaults[$propName] = $this->getDefault($propSchema, $localeParams, $locale); |
| 501 | } |
| 502 | |
| 503 | return $defaults; |
| 504 | } |
| 492 | public function getLocaleDefaults($schemaName, $locale, $localeParams) |
| 493 | { |
| 494 | $schema = $this->get($schemaName); |
| 495 | $defaults = []; |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 498 | continue; |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 498 | continue; |
| 499 | } |
| 500 | $defaults[$propName] = $this->getDefault($propSchema, $localeParams, $locale); |
| 501 | } |
| 502 | |
| 503 | return $defaults; |
| 504 | } |
| 492 | public function getLocaleDefaults($schemaName, $locale, $localeParams) |
| 493 | { |
| 494 | $schema = $this->get($schemaName); |
| 495 | $defaults = []; |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 498 | continue; |
| 499 | } |
| 500 | $defaults[$propName] = $this->getDefault($propSchema, $localeParams, $locale); |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 498 | continue; |
| 499 | } |
| 500 | $defaults[$propName] = $this->getDefault($propSchema, $localeParams, $locale); |
| 501 | } |
| 502 | |
| 503 | return $defaults; |
| 504 | } |
| 492 | public function getLocaleDefaults($schemaName, $locale, $localeParams) |
| 493 | { |
| 494 | $schema = $this->get($schemaName); |
| 495 | $defaults = []; |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 498 | continue; |
| 499 | } |
| 500 | $defaults[$propName] = $this->getDefault($propSchema, $localeParams, $locale); |
| 501 | } |
| 502 | |
| 503 | return $defaults; |
| 504 | } |
| 492 | public function getLocaleDefaults($schemaName, $locale, $localeParams) |
| 493 | { |
| 494 | $schema = $this->get($schemaName); |
| 495 | $defaults = []; |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 496 | foreach ($schema->properties as $propName => $propSchema) { |
| 497 | if (empty($propSchema->multilingual) || empty($propSchema->defaultLocaleKey)) { |
| 498 | continue; |
| 499 | } |
| 500 | $defaults[$propName] = $this->getDefault($propSchema, $localeParams, $locale); |
| 501 | } |
| 502 | |
| 503 | return $defaults; |
| 504 | } |
| 220 | public function getMultilingualProps($schemaName) |
| 221 | { |
| 222 | $schema = $this->get($schemaName); |
| 223 | |
| 224 | $multilingualProps = []; |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 226 | if (!empty($propSchema->multilingual)) { |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 226 | if (!empty($propSchema->multilingual)) { |
| 227 | $multilingualProps[] = $propName; |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 226 | if (!empty($propSchema->multilingual)) { |
| 227 | $multilingualProps[] = $propName; |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | return $multilingualProps; |
| 232 | } |
| 220 | public function getMultilingualProps($schemaName) |
| 221 | { |
| 222 | $schema = $this->get($schemaName); |
| 223 | |
| 224 | $multilingualProps = []; |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 226 | if (!empty($propSchema->multilingual)) { |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 226 | if (!empty($propSchema->multilingual)) { |
| 227 | $multilingualProps[] = $propName; |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | return $multilingualProps; |
| 232 | } |
| 220 | public function getMultilingualProps($schemaName) |
| 221 | { |
| 222 | $schema = $this->get($schemaName); |
| 223 | |
| 224 | $multilingualProps = []; |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 226 | if (!empty($propSchema->multilingual)) { |
| 227 | $multilingualProps[] = $propName; |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | return $multilingualProps; |
| 232 | } |
| 220 | public function getMultilingualProps($schemaName) |
| 221 | { |
| 222 | $schema = $this->get($schemaName); |
| 223 | |
| 224 | $multilingualProps = []; |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 225 | foreach ($schema->properties as $propName => $propSchema) { |
| 226 | if (!empty($propSchema->multilingual)) { |
| 227 | $multilingualProps[] = $propName; |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | return $multilingualProps; |
| 232 | } |
| 203 | public function getRequiredProps($schemaName) |
| 204 | { |
| 205 | $schema = $this->get($schemaName); |
| 206 | |
| 207 | if (!empty($schema->required)) { |
| 208 | return $schema->required; |
| 203 | public function getRequiredProps($schemaName) |
| 204 | { |
| 205 | $schema = $this->get($schemaName); |
| 206 | |
| 207 | if (!empty($schema->required)) { |
| 210 | return []; |
| 211 | } |
| 159 | public function getSummaryProps($schemaName) |
| 160 | { |
| 161 | $schema = $this->get($schemaName); |
| 162 | $props = []; |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 165 | $props[] = $propName; |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 165 | $props[] = $propName; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | return $props; |
| 170 | } |
| 159 | public function getSummaryProps($schemaName) |
| 160 | { |
| 161 | $schema = $this->get($schemaName); |
| 162 | $props = []; |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 165 | $props[] = $propName; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | return $props; |
| 170 | } |
| 159 | public function getSummaryProps($schemaName) |
| 160 | { |
| 161 | $schema = $this->get($schemaName); |
| 162 | $props = []; |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 165 | $props[] = $propName; |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 165 | $props[] = $propName; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | return $props; |
| 170 | } |
| 159 | public function getSummaryProps($schemaName) |
| 160 | { |
| 161 | $schema = $this->get($schemaName); |
| 162 | $props = []; |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 165 | $props[] = $propName; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | return $props; |
| 170 | } |
| 159 | public function getSummaryProps($schemaName) |
| 160 | { |
| 161 | $schema = $this->get($schemaName); |
| 162 | $props = []; |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 165 | $props[] = $propName; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | return $props; |
| 170 | } |
| 159 | public function getSummaryProps($schemaName) |
| 160 | { |
| 161 | $schema = $this->get($schemaName); |
| 162 | $props = []; |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 163 | foreach ($schema->properties as $propName => $propSchema) { |
| 164 | if (!empty($propSchema->apiSummary) && empty($propSchema->writeOnly)) { |
| 165 | $props[] = $propName; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | return $props; |
| 170 | } |
| 338 | public function getValidationRules($schemaName, $allowedLocales) |
| 339 | { |
| 340 | $schema = $this->get($schemaName); |
| 341 | |
| 342 | $rules = []; |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 344 | if (!empty($propSchema->multilingual)) { |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 346 | $rules = $this->addPropValidationRules($rules, $propName . '.' . $localeKey, $propSchema); |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 344 | if (!empty($propSchema->multilingual)) { |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 344 | if (!empty($propSchema->multilingual)) { |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 346 | $rules = $this->addPropValidationRules($rules, $propName . '.' . $localeKey, $propSchema); |
| 347 | } |
| 348 | } else { |
| 349 | $rules = $this->addPropValidationRules($rules, $propName, $propSchema); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | return $rules; |
| 354 | } |
| 338 | public function getValidationRules($schemaName, $allowedLocales) |
| 339 | { |
| 340 | $schema = $this->get($schemaName); |
| 341 | |
| 342 | $rules = []; |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 344 | if (!empty($propSchema->multilingual)) { |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 344 | if (!empty($propSchema->multilingual)) { |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 344 | if (!empty($propSchema->multilingual)) { |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 346 | $rules = $this->addPropValidationRules($rules, $propName . '.' . $localeKey, $propSchema); |
| 347 | } |
| 348 | } else { |
| 349 | $rules = $this->addPropValidationRules($rules, $propName, $propSchema); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | return $rules; |
| 354 | } |
| 338 | public function getValidationRules($schemaName, $allowedLocales) |
| 339 | { |
| 340 | $schema = $this->get($schemaName); |
| 341 | |
| 342 | $rules = []; |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 344 | if (!empty($propSchema->multilingual)) { |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 344 | if (!empty($propSchema->multilingual)) { |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 344 | if (!empty($propSchema->multilingual)) { |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 346 | $rules = $this->addPropValidationRules($rules, $propName . '.' . $localeKey, $propSchema); |
| 347 | } |
| 348 | } else { |
| 349 | $rules = $this->addPropValidationRules($rules, $propName, $propSchema); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | return $rules; |
| 354 | } |
| 338 | public function getValidationRules($schemaName, $allowedLocales) |
| 339 | { |
| 340 | $schema = $this->get($schemaName); |
| 341 | |
| 342 | $rules = []; |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 344 | if (!empty($propSchema->multilingual)) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 344 | if (!empty($propSchema->multilingual)) { |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 346 | $rules = $this->addPropValidationRules($rules, $propName . '.' . $localeKey, $propSchema); |
| 347 | } |
| 348 | } else { |
| 349 | $rules = $this->addPropValidationRules($rules, $propName, $propSchema); |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 344 | if (!empty($propSchema->multilingual)) { |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 346 | $rules = $this->addPropValidationRules($rules, $propName . '.' . $localeKey, $propSchema); |
| 347 | } |
| 348 | } else { |
| 349 | $rules = $this->addPropValidationRules($rules, $propName, $propSchema); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | return $rules; |
| 354 | } |
| 338 | public function getValidationRules($schemaName, $allowedLocales) |
| 339 | { |
| 340 | $schema = $this->get($schemaName); |
| 341 | |
| 342 | $rules = []; |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 344 | if (!empty($propSchema->multilingual)) { |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 346 | $rules = $this->addPropValidationRules($rules, $propName . '.' . $localeKey, $propSchema); |
| 347 | } |
| 348 | } else { |
| 349 | $rules = $this->addPropValidationRules($rules, $propName, $propSchema); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | return $rules; |
| 354 | } |
| 338 | public function getValidationRules($schemaName, $allowedLocales) |
| 339 | { |
| 340 | $schema = $this->get($schemaName); |
| 341 | |
| 342 | $rules = []; |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 343 | foreach ($schema->properties as $propName => $propSchema) { |
| 344 | if (!empty($propSchema->multilingual)) { |
| 345 | foreach ($allowedLocales as $localeKey) { |
| 346 | $rules = $this->addPropValidationRules($rules, $propName . '.' . $localeKey, $propSchema); |
| 347 | } |
| 348 | } else { |
| 349 | $rules = $this->addPropValidationRules($rules, $propName, $propSchema); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | return $rules; |
| 354 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 126 | $newSchema->title = $additionalSchema->title; |
| 127 | } |
| 128 | if (!empty($additionalSchema->description)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 129 | $newSchema->description = $additionalSchema->description; |
| 130 | } |
| 131 | if (!empty($additionalSchema->required)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 132 | $required = property_exists($baseSchema, 'required') |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 132 | $required = property_exists($baseSchema, 'required') |
| 133 | ? $baseSchema->required |
| 134 | : []; |
| 135 | $newSchema->required = array_unique(array_merge($required, $additionalSchema->required)); |
| 136 | } |
| 137 | if (!empty($additionalSchema->properties)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 139 | $newSchema->properties = new \stdClass(); |
| 140 | } |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 138 | if (empty($newSchema->properties)) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 141 | foreach ($additionalSchema->properties as $propName => $propSchema) { |
| 142 | $newSchema->properties->{$propName} = $propSchema; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return $newSchema; |
| 146 | return $newSchema; |
| 147 | } |
| 122 | public function merge($baseSchema, $additionalSchema) |
| 123 | { |
| 124 | $newSchema = clone $baseSchema; |
| 125 | if (!empty($additionalSchema->title)) { |
| 128 | if (!empty($additionalSchema->description)) { |
| 131 | if (!empty($additionalSchema->required)) { |
| 137 | if (!empty($additionalSchema->properties)) { |
| 146 | return $newSchema; |
| 147 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 245 | public function sanitize($schemaName, $props) |
| 246 | { |
| 247 | $schema = $this->get($schemaName); |
| 248 | $cleanProps = []; |
| 249 | |
| 250 | foreach ($props as $propName => $propValue) { |
| 250 | foreach ($props as $propName => $propValue) { |
| 251 | if (empty($schema->properties->{$propName}) |
| 252 | || empty($schema->properties->{$propName}->type) |
| 253 | || !empty($schema->properties->{$propName}->readOnly)) { |
| 254 | continue; |
| 255 | } |
| 256 | $propSchema = $schema->properties->{$propName}; |
| 257 | if (!empty($propSchema->multilingual)) { |
| 258 | $values = []; |
| 259 | foreach ((array) $propValue as $localeKey => $localeValue) { |
| 260 | $values[$localeKey] = $this->coerce($localeValue, $propSchema->type, $propSchema); |
| 261 | } |
| 262 | if (!empty($values)) { |
| 263 | $cleanProps[$propName] = $values; |
| 264 | } |
| 265 | } else { |
| 266 | $cleanProps[$propName] = $this->coerce($propValue, $propSchema->type, $propSchema); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return $cleanProps; |
| 271 | } |
| 458 | public function setDefaults($schemaName, $object, $supportedLocales, $primaryLocale, $localeParams = []) |
| 459 | { |
| 460 | $schema = $this->get($schemaName); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 478 | } |
| 479 | |
| 480 | return $object; |
| 481 | } |
| 458 | public function setDefaults($schemaName, $object, $supportedLocales, $primaryLocale, $localeParams = []) |
| 459 | { |
| 460 | $schema = $this->get($schemaName); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 478 | } |
| 479 | |
| 480 | return $object; |
| 481 | } |
| 458 | public function setDefaults($schemaName, $object, $supportedLocales, $primaryLocale, $localeParams = []) |
| 459 | { |
| 460 | $schema = $this->get($schemaName); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 478 | } |
| 479 | |
| 480 | return $object; |
| 481 | } |
| 458 | public function setDefaults($schemaName, $object, $supportedLocales, $primaryLocale, $localeParams = []) |
| 459 | { |
| 460 | $schema = $this->get($schemaName); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 478 | } |
| 479 | |
| 480 | return $object; |
| 481 | } |
| 458 | public function setDefaults($schemaName, $object, $supportedLocales, $primaryLocale, $localeParams = []) |
| 459 | { |
| 460 | $schema = $this->get($schemaName); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 478 | } |
| 479 | |
| 480 | return $object; |
| 481 | } |
| 458 | public function setDefaults($schemaName, $object, $supportedLocales, $primaryLocale, $localeParams = []) |
| 459 | { |
| 460 | $schema = $this->get($schemaName); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 469 | if (!empty($propSchema->multilingual)) { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 478 | } |
| 479 | |
| 480 | return $object; |
| 481 | } |
| 458 | public function setDefaults($schemaName, $object, $supportedLocales, $primaryLocale, $localeParams = []) |
| 459 | { |
| 460 | $schema = $this->get($schemaName); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 478 | } |
| 479 | |
| 480 | return $object; |
| 481 | } |
| 458 | public function setDefaults($schemaName, $object, $supportedLocales, $primaryLocale, $localeParams = []) |
| 459 | { |
| 460 | $schema = $this->get($schemaName); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 478 | } |
| 479 | |
| 480 | return $object; |
| 481 | } |
| 458 | public function setDefaults($schemaName, $object, $supportedLocales, $primaryLocale, $localeParams = []) |
| 459 | { |
| 460 | $schema = $this->get($schemaName); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 478 | } |
| 479 | |
| 480 | return $object; |
| 481 | } |
| 458 | public function setDefaults($schemaName, $object, $supportedLocales, $primaryLocale, $localeParams = []) |
| 459 | { |
| 460 | $schema = $this->get($schemaName); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 478 | } |
| 479 | |
| 480 | return $object; |
| 481 | } |
| 458 | public function setDefaults($schemaName, $object, $supportedLocales, $primaryLocale, $localeParams = []) |
| 459 | { |
| 460 | $schema = $this->get($schemaName); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 469 | if (!empty($propSchema->multilingual)) { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 478 | } |
| 479 | |
| 480 | return $object; |
| 481 | } |
| 458 | public function setDefaults($schemaName, $object, $supportedLocales, $primaryLocale, $localeParams = []) |
| 459 | { |
| 460 | $schema = $this->get($schemaName); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 478 | } |
| 479 | |
| 480 | return $object; |
| 481 | } |
| 458 | public function setDefaults($schemaName, $object, $supportedLocales, $primaryLocale, $localeParams = []) |
| 459 | { |
| 460 | $schema = $this->get($schemaName); |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 461 | foreach ($schema->properties as $propName => $propSchema) { |
| 462 | // Don't override existing values |
| 463 | if (!is_null($object->getData($propName))) { |
| 464 | continue; |
| 465 | } |
| 466 | if (!property_exists($propSchema, 'default') && !property_exists($propSchema, 'defaultLocaleKey')) { |
| 467 | continue; |
| 468 | } |
| 469 | if (!empty($propSchema->multilingual)) { |
| 470 | $value = []; |
| 471 | foreach ($supportedLocales as $localeKey) { |
| 472 | $value[$localeKey] = $this->getDefault($propSchema, $localeParams, $localeKey); |
| 473 | } |
| 474 | } else { |
| 475 | $value = $this->getDefault($propSchema, $localeParams, $primaryLocale); |
| 476 | } |
| 477 | $object->setData($propName, $value); |
| 478 | } |
| 479 | |
| 480 | return $object; |
| 481 | } |